<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>测试前后台交互</title>
</head>
<body>
    <button type="button" id="btn" onclick="update()">点击</button>
</body>
</html>
<script type="text/javascript" src="/js/1.8.2.min.js"></script>
<script>
    function update(){
        alert("1");
        var d = {};
        d.userId = 30;
        d.username = "Sunpeng.Guo";
        $.ajax({
            url: "/L/I",
            data: {},
            //type、contentType必填,指明传参方式
            type: "POST",
            contentType: "application/json;charset=utf-8",
            success: function(response){
                alert("123456");
                //前端调用成功后，可以处理后端传回的json格式数据。
            }

        });
    }
</script>